package com.softwareconstruction;

import java.util.List;
import com.softwareconstruction.model.Paper;
import com.softwareconstruction.model.Thesis;
import com.softwareconstruction.model.JournalPaper;
import com.softwareconstruction.model.ConferencePaper;
import com.softwareconstruction.service.PaperList;
import com.softwareconstruction.service.RandomSelectionStrategy;
import com.softwareconstruction.service.SequentialSelectionStrategy;
import com.softwareconstruction.exception.NoEnoughPapersException;

public class Client {
    public static void main(String[] args) {
        PaperList paperList = new PaperList();
        
        // 添加示例论文
        paperList.addPaper(new Thesis("博士学位论文", "张三", "李四教授"));
        paperList.addPaper(new JournalPaper("期刊论文示例", "王五", "计算机学报", 3.5));
        paperList.addPaper(new ConferencePaper("会议论文示例", "赵六", "ICSE 2023", "美国波士顿"));
        
        System.out.println("总论文数量: " + paperList.getPaperCount());
        
        // 顺序选择策略
        try {
            List<Paper> sequentialPapers = paperList.selectPapers(new SequentialSelectionStrategy(), 2);
            System.out.println("顺序选择结果: ");
            sequentialPapers.forEach(paper -> System.out.println(paper.getTitle()));
        } catch (NoEnoughPapersException e) {
            System.err.println("顺序选择失败: " + e.getMessage());
        }
        
        // 随机选择策略
        try {
            List<Paper> randomPapers = paperList.selectPapers(new RandomSelectionStrategy(), 2);
            System.out.println("随机选择结果: ");
            randomPapers.forEach(paper -> System.out.println(paper.getTitle()));
        } catch (NoEnoughPapersException e) {
            System.err.println("随机选择失败: " + e.getMessage());
        }
    }
}